<template>
  <div class="manage-view-wrapper">
    <div class="title">
      <item-list :items="categoriesCover" :idx="categoryIdx"
      class="category-list" @changeIdx="changeCategory"></item-list>
    </div>

    <span></span>

    <router-view></router-view>
  </div>
</template>

<script>
import ItemList from '@/components/utils/ItemList.vue'

  export default {
    components: {
      ItemList,
    },
    data() {
      return {
        categories: [
          'draft', 'published'
        ],
        categoriesCover: [
          '草稿箱', '已发布'
        ],
      }
    },
    computed: {
      categoryIdx() {
        return this.categories.includes(this.$route.query.q)
          ? this.categories.indexOf(this.$route.query.q)
          : 0
      }
    },
    methods: {
      changeCategory(idx) {
        this.$router.push({
          path: this.$route.path,
          query: {
            q: this.categories[idx]
          }
        })
      }
    },
    watch: {
    },
    mounted () {
    },
  }
</script>

<style lang="less" scoped>
@w: var(--w);
@fs: calc(@w * 0.01);

.manage-view-wrapper {
  width: @w;

  .title {
    --th: calc(@w * 0.06);
    --fs: calc(var(--th) * 0.4);
    box-sizing: border-box;
    width: @w;
    height: var(--th);
    line-height: var(--th);
    font-size: var(--fs);
    text-indent: var(--fs);

    .category-list {
      --itemListWidth: calc(@w * 0.6);
      --itemListHeight: var(--th);
      --itemNum: 3;
      text-indent: 0;
    }
  }

  span {
    display: block;
    width: @w;
    height: 1px;
    background-color: var(--gray);
  }
}
</style>